﻿namespace Sidvall.Security
{
    public class TokenItem
    {
        #region Public Members

        public string IdentityToken { get; set; }
        public string RefreshToken { get; set; }

        #region Import

        public void Import(TokenResponse tokenResponse)
        {
            if (tokenResponse == null)
                return;
            this.RefreshToken = tokenResponse.RefreshToken;
            if (!string.IsNullOrWhiteSpace(tokenResponse.IdentityToken))
                this.IdentityToken = tokenResponse.IdentityToken;
        }

        #endregion
        #region Create

        public static TokenItem Create(TokenResponse tokenResponse)
        {
            if (tokenResponse == null)
                return null;
            return new TokenItem()
            {
                IdentityToken = tokenResponse.IdentityToken,
                RefreshToken = tokenResponse.RefreshToken,
            };
        }

        #endregion

        #endregion
    }
}
